<html>
<head>
<title>Article Form</title>
	<link rel="stylesheet" type="text/css" href="<?=base_url();?>public/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="<?=base_url();?>public/css/bootstrap-theme.min.css">
	<link rel="stylesheet" type="text/css" href="<?=base_url();?>public/css/style.css">
  <!--[if lt IE 9]>
    <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
  <![endif]-->
  <script charset="utf-8" src="<?=base_url()?>public/kindeditor/kindeditor-all-min.js"></script>
  <script charset="utf-8" src="<?=base_url()?>public/kindeditor/lang/zh-CN.js"></script>
  <script type="text/javascript" src="<?=base_url()?>public/js/jquery.upload.js"></script>
</head>
<body>
<div class="container">
  <div class="row">
    <div class="col-md-10">
      <div class="page-header">
        <h1><?=$title;?>文章</h1>
      </div>

      <div>
          <div class="panel-body">
            <form class="form-horizontal" action="" method="post">
              <div  class="form-group">
              <label class="col-sm-3 control-label"><b style="color:red;">*</b>分　类：</label>
                <div class="col-sm-3">
                  <select class="form-control" name="catalog_id">
                      <option value="">请选择一个分类</option>
                      <?php foreach($catalogs as $catalog){?>
                        <option <?=set_select('catalog_id', $catalog->id,$catalog->id==$article->catalog_id);?> value="<?=$catalog->id?>"><?=$catalog->class?></option>
                      <?php }?>
                  </select>
                  <?php echo form_error('cata_id', '<div class="error">', '</div>'); ?>
                </div>
              </div>

              <div class="form-group">
                <label class="col-sm-3 control-label"><b style="color:red;">*</b>标　题：</label>
                <div class="col-sm-9">
                  <input type="text" name="title" value="<?=set_value('title',$article->title)?>" class="form-control">
                  <?php echo form_error('title', '<div class="error">', '</div>'); ?>
                </div>
              </div>

               <div class="form-group">
                <label class="col-sm-3 control-label"><b style="color:red;">*</b>图　片：</label>
                <div class="col-sm-5">
                  <input type="text" id="img" name="img" value="<?=set_value('img',$article->img)?>" class="form-control">
                  <a id="upload" href="#">上传文件</a>
                  <?php echo form_error('img', '<div class="error">', '</div>'); ?>
                 
                </div>
                 <div class="col-sm-4" id="preview" ></div>
              </div>

              <div class="form-group">
                <label class="col-sm-3 control-label"><b style="color:red;">*</b>简　介：</label>
                <div class="col-sm-9">
                  <textarea class="form-control" name="desc" rows="3"><?=set_value('desc',$article->desc)?></textarea>
                  <?php echo form_error('desc', '<div class="error">', '</div>'); ?>
                </div>
              </div>

              <div class="form-group">
                <label class="col-sm-3 control-label"><b style="color:red;">*</b>内　容：</label>
                <div class="col-sm-9">
                  <textarea class="form-control content" name="content" rows="6" ><?=set_value('content',$article->content)?></textarea>
                  <?php echo form_error('content', '<div class="error">', '</div>'); ?>
                </div>
              </div>
             

              <div class="form-group">
                <label class="col-sm-3 control-label"></label>
                <div class="col-sm-9">
                  <button type="submit" class="btn  btn-success">提　交</button>
                  <a href="<?=site_url('/admin/article/index/')?>">返　回</a>
                </div>
              </div>           
            </form>
          </div>
      </div>
    </div>
  </div>
</div>
<script>
  KindEditor.create('.content');

  $('#upload').click(function(){
     $.upload({
        url: '<?php echo site_url("admin/util/upload")?>', 
        fileName: 'file', 
        dataType: 'text',
        onSend: function() {
                return true;
        },
        onComplate: function(data) {
          if(data.indexOf("upload") > 0 ){
            $("#img").val(data);
            $("#preview").html('<img style="height:80px;" src="<?php echo base_url()?>'+data+'" />')
          }else{
            alert(data);
          }
        }
    });
     return false;
  });

</script>

</body>
</html>